import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";

export enum ItemType {
  MEDICINE = 1, // 药品
  POWER_POTION = 2, // 精力药水
  TREASURE = 3, // 宝物
  EXPERIENCE_BOOK = 4, // 经验书
  KEY = 5, // 钥匙
  BOX = 6, // 宝盒
  TOKEN = 7, // 令牌
  OTHER = 8, // 其他
}

export enum ItemRarity {
  COMMON = 1, // 普通
  UNCOMMON = 2, // 优秀
  RARE = 3, // 稀有
  EPIC = 4, // 史诗
  LEGENDARY = 5, // 传说
}

@Entity("items")
@ManualTimestamp()
export class ItemEntity {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column("varchar", { length: 100, comment: "物品名称" })
  name!: string;

  @Column("varchar", { length: 500, comment: "物品描述" })
  description!: string;

  @Column("varchar", { length: 100, comment: "物品图片" })
  picture!: string;

  @Column("int", { comment: "物品类型" })
  itemType!: ItemType;

  @Column("int", { comment: "物品稀有度" })
  rarity!: ItemRarity;

  @Column("int", { comment: "物品等级" })
  level!: number;

  @Column("int", { comment: "金币价格" })
  goldPrice!: number;

  @Column("int", { comment: "银两价格" })
  silverPrice!: number;

  @Column("int", { comment: "积分价格" })
  pointPrice!: number;

  @Column("varchar", { length: 50, comment: "物品效果值" })
  effectValue!: string;

  @Column("int", { comment: "是否上架商店", default: 0 })
  isOnSale!: number;

  @Column("int", { comment: "是否上架积分商城", default: 0 })
  isOnPointShop!: number;

  @Column("int", { comment: "每日限购数量", default: 0 })
  dailyLimit!: number;

  @Column("int", { comment: "库存数量", default: -1 })
  stock!: number;

  @Column("int", { comment: "物品状态", default: 1 })
  status!: number;

  @Column("varchar", { length: 200, comment: "备注" })
  remark!: string;

  @Column("datetime", { name: "created_at", comment: "创建时间" })
  created_at!: Date;
@Column("datetime", { name: "updated_at", nullable: true, comment: "更新时间" })
  updated_at!: Date | null;
}
